import "package:ct_pa_majordomo/config/theme_vars.dart";
import "package:ct_pa_majordomo/widgets/divider/solid_divider.dart";
import "package:flutter/material.dart";

class Section extends StatelessWidget {
  final String title;
  final EdgeInsets contentPadding;
  final Widget child;
  final Widget? moreAction;
  final Color? color;

  const Section({
    super.key,
    required this.title,
    this.contentPadding = const EdgeInsets.symmetric(horizontal: 15),
    required this.child,
    this.moreAction,
    this.color,
  });

  @override
  Widget build(BuildContext context) {
    return DecoratedBox(
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(12),
        boxShadow: const [ThemeVars.boxShadow],
        color: color ?? ThemeVars.colorPrimaryLight,
      ),
      child: Column(
        children: [
          const SizedBox(height: 15),
          Row(
            children: [
              const SizedBox(width: 15),
              const SolidDivider(
                color: ThemeVars.colorPrimaryDark,
                direction: Axis.vertical,
                height: 16,
                strokeWidth: 3,
              ),
              const SizedBox(width: 10),
              Text(title, style: const TextStyle(fontSize: 18)),
              if (moreAction != null)
                const Expanded(child: SizedBox()),
              if (moreAction != null)
                Padding(padding: const EdgeInsets.symmetric(horizontal: 15), child: moreAction,),
            ],
          ),
          const SizedBox(height: 15),
          Padding(padding: contentPadding, child: child),
          const SizedBox(height: 15),
        ],
      ),
    );
  }
}
